package org.feiye.studyday28.two;

import java.io.*;
import java.net.*;
import java.util.*;

public class Client {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Socket s = null;
		try {
			// 创建客户端
			s = new Socket("localhost", 5555);
			// 打开输入输出流
			InputStream in = s.getInputStream();
			OutputStream out = s.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			ObjectOutputStream oos = new ObjectOutputStream(out);
			while (true) {
				User user = new User();
				System.out.println("请输入账号：");
				user.setAct(input.next());
				System.out.println("请输入密码：");
				user.setPsd(input.next());
				oos.writeObject(user);
				oos.flush();
				String str = br.readLine();
				System.out.println(str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (s != null) {
				try {
					s.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

	}

}
